/**
 * Classname :PositionCacheStartup.java
 *
 * Version information: 1.0
 *
 * Date: Mar 09, 2012 Bui.Trung.Dung create
 *
 */

package com.history.app;

import java.util.List;

import com.history.business.ArticleManager;
import com.history.common.Logit;
import com.history.common.SpringContextFactory;
import com.history.domain.bean.Article;
import com.history.scheduler.SchedulerFactory;

/**
 * 
 * @author Bui.Trung.Dung Created Mar 09, 2012
 */
public class AppStartup {

	private static Logit m_log = Logit.getInstance(AppStartup.class);

	public static void main(String[] args) {
		AppStartup crcs = new AppStartup();
		crcs.startUp();
	}

	private void startUp() {
		try {
			
			// Int Scheduler
			SchedulerFactory.getInstance();
			
			ArticleManager articleManagerLocal = SpringContextFactory.getArticleManager(false);
			List<Article> articleList = articleManagerLocal.findAll();
			if (articleList != null && articleList.size() > 0) {
				
				String data[][] = new String[articleList.size()][4];
				for (int i = 0; i < articleList.size(); i++) {
					data[i][0] = articleList.get(i).getId();
					data[i][1] = articleList.get(i).getTitle();
					data[i][2] = articleList.get(i).getContent();
					data[i][3] = articleList.get(i).getUpdateDate().toLocaleString();
				}
				new GridLine(data);
			}

		} catch (Exception e) {
			m_log.error("Startup error:" + e.getMessage(), e);
			// TODO: handle exception
		}
	}
}